# =============================================================
# Makefile 
# ---------------------------------------
# Author : Woo-Hyun Kim
# Email : woorung@icu.ac.kr or woorung@nhncorp.com
# Date : Jul. 10, 2006
# =============================================================
include ../../etc/profile.mk

# common configuration
CC = g++
LEX = flex
YACC = bison
FLEX_DEFS = -8
#DEFS = -Wno-deprecated -DTRACE
#DEFS = -Wno-deprecated -DDEBUG

OBJS = CInfoMap.o CIndexInterpreter.o CCubeInterpreter.o CWork.o CTask.o imap_l.o imap_y.o
EXES = check_tdl xtask

all : $(OBJS) lib lib-allinone $(EXES)

xtask : xtask.o
	$(CC) -o $@ $< $(WNL)/libwn.a $(WNL)/libcommon.a
	@echo $@ is completed.

check_tdl : check_tdl.o
	$(CC) -o $@ $< $(WNL)/libwn.a $(WNL)/libcommon.a
	@echo $@ is completed.

xtask.o : xtask.cpp
	$(CC) -c xtask.cpp $(DEFS) -I$(WNI)

check_tdl.o : check_tdl.cpp
	$(CC) -c check_tdl.cpp $(DEFS) -I$(WNI)

CInfoMap.o : CInfoMap.cpp
	$(CC) -c CInfoMap.cpp $(DEFS) -I$(WNI)

CIndexInterpreter.o : CIndexInterpreter.cpp
	$(CC) -c $< $(DEFS) -I$(WNI)

CCubeInterpreter.o : CCubeInterpreter.cpp
	$(CC) -c $< $(DEFS) -I$(WNI)

CWork.o : CWork.cpp
	$(CC) -c $< $(DEFS) -I$(WNI)

CTask.o : CTask.cpp
	$(CC) -c $< $(DEFS) -I$(WNI)

imap_l.c : imap.l
	$(LEX) $(FLEX_DEFS) -oimap_l.c $<
	$(CC) -c imap_l.c $(DEFS) -I$(WNI)

imap_l.o : imap_y.c imap_l.c
	$(CC) -c imap_l.c $(DEFS) -I$(WNI)

imap_y.c : imap.y
	$(YACC) -oimap_y.c -d $<

imap_y.o : imap_y.c
	$(CC) -c imap_y.c $(DEFS) -I$(WNI)

lib :
	ar -ruv $(WNL)/libwn.a CInfoMap.o imap_l.o imap_y.o CIndexInterpreter.o CCubeInterpreter.o CWork.o CTask.o
	ranlib $(WNL)/libwn.a
	cp *.h $(WNI)/
	@echo CInfoMap.o imap_l.o imap_y.o CIndexInterpreter.o CCubeInterpreter.o CWork.o CTask.o were added to libwn.a

lib-allinone :
	ar -ruv $(WNL)/libwn-allinone.a CInfoMap.o imap_l.o imap_y.o CIndexInterpreter.o CCubeInterpreter.o CWork.o CTask.o
	ranlib $(WNL)/libwn-allinone.a
	@echo libwn-allinone.a completed.

clean :
	$(RM) *.o check_tdl xtask $(EXES) imap_l.c imap_y.c imap_y.h
